package 集合;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

public class TestCollections {

    public static void main(String[] args) {
        List list=new ArrayList();
        list.add(1);
        list.add(15);
        list.add(10);
        list.add(-5);
        System.out.println(list);//[1, 15, 10, -5]
        //Collections --- sort(List list)
        Collections.sort(list);//元素要是可以排序！！！
        System.out.println(list);//[-5, 1, 10, 15]
        //Collections --- shuffle(List list)
        Collections.shuffle(list);//????  随机交接元素位置  把集合顺序随机排列
        System.out.println(list);
        Collections.shuffle(list);//????
        System.out.println(list);

        System.out.println(Collections.max(list));//15
        System.out.println(Collections.min(list));//-5
        //Collections --- fill()
        Collections.fill(list,100);//[100, 100, 100, 100]
        System.out.println(list);

        List list2=new ArrayList();//6个-1
        list2.add(-1);
        list2.add(-1);
        list2.add(-1);
        list2.add(-1);
        list2.add(-1);
        list2.add(-1);
        //注意：list2.size()>=list.size()!!!
        Collections.copy(list2,list);//把list中的元素复制给list2    list(4)    list2(0)
        System.out.println(list2);//

    }
}
